package com.micro.ai.files.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 文件上传记录实体类
 * 用于管理分片上传的状态
 * 
 * @author micro-ai
 * @since 0.0.1
 */
@Data
@TableName("file_upload_records")
@Schema(description = "文件上传记录信息")
public class FileUploadRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "记录ID", example = "record_123456789")
    private String id;

    /**
     * 租户ID
     */
    @Schema(description = "租户ID", example = "tenant_001")
    private String tenantId;

    /**
     * 上传会话ID（唯一标识一次上传任务）
     */
    @Schema(description = "上传会话ID", example = "upload_abc123xyz")
    private String uploadId;

    /**
     * 文件名
     */
    @Schema(description = "文件名", example = "large-file.zip")
    private String filename;

    /**
     * 文件大小（字节）
     */
    @Schema(description = "文件大小（字节）", example = "10485760")
    private Long fileSize;

    /**
     * 总分片数
     */
    @Schema(description = "总分片数", example = "10")
    private Integer totalChunks;

    /**
     * 已上传分片数
     */
    @Schema(description = "已上传分片数", example = "5")
    private Integer uploadedChunks;

    /**
     * 分块大小(默认5MB)
     */
    @Schema(description = "分块大小(字节)", example = "5242880")
    private Integer chunkSize;

    /**
     * 文件哈希
     */
    @Schema(description = "文件哈希", example = "abc123...")
    private String fileHash;

    /**
     * 状态：uploading-上传中, completed-已完成, failed-失败, cancelled-已取消
     */
    @Schema(description = "状态", example = "uploading", allowableValues = {"uploading", "completed", "failed", "cancelled"})
    private String status;

    /**
     * 上传者ID
     */
    @Schema(description = "上传者ID", example = "user_001")
    private String uploaderId;

    /**
     * 目标文件夹
     */
    @Schema(description = "目标文件夹ID", example = "folder_123")
    private String folderId;

    /**
     * 上传会话过期时间
     */
    @Schema(description = "上传会话过期时间")
    private LocalDateTime expiredAt;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2025-01-01 00:00:00")
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间", example = "2025-01-01 00:00:00")
    private LocalDateTime updatedAt;
}

